package com.huanzhidadi.single.randomarray;

public class RandomArray {
    private static final String colors[] =
            { "Red", "Green", "Blue", "White", "Black" };
    public static void main(String[] args) {

        for(int i=0; i < 20; ++i) {
            String randomColor = getRandomColor();
            System.out.println(randomColor);
//            System.out.println(getRandomX());
//            System.out.println(getRandomY());
        }
    }
    private static String getRandomColor() {
        return colors[(int)(Math.random()*colors.length)];
        /*double random = Math.random();
        System.out.println("random:" + random);
        int length = colors.length;
        System.out.println("length:" + length);
        double v = random * colors.length;
        System.out.println("v:" + v);
        int index = (int) v;
        System.out.println("index:" + index);
        return colors[index];*/
    }
    private static int getRandomX() {
        return (int)(Math.random()*100 );
    }
    private static int getRandomY() {
        return (int)(Math.random()*100);
    }
}
